from django.shortcuts import render
from roles.rolesDAO import userDAO
import logging
import json

rolesDao = userDAO()
def adminIndexPage(request):
    if 'navStatus' in request.GET:
        navStatus = request.GET['navStatus']
    else:
        navStatus = 'userList'
    print("navStatus="+navStatus)

    if navStatus == 'userList':
        tableHead = ["userId","userName","realName","passWord","email","isActive","isSuper","groupId"]
        tableData = rolesDao.getUserList()
    elif navStatus == 'userGroupList':
        tableHead = ["groupId","groupName", "isActive"]
        tableData = rolesDao.getGroupList()
    elif navStatus == 'rolesList':
        tableHead = ["roleId","roleName", "key","isActive","classStyle","url"]
        tableData = rolesDao.getRoleList()
    context = {'tableHead':tableHead,'tableData':tableData,"navStatus":navStatus}
    return render(request,
                  'roles/admin_index.html',
                  context
                  )